import requests


class DefManageApi(object):
    def add_def(self, req_head, req_data):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                             headers=req_head, json=req_data)
        return resp

    def query_def(self, def_id, req_head):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/company/department/" + def_id,
                            headers=req_head)
        return resp

    def modify_def(self, emp_id, req_head, req_data):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/company/department/" + emp_id,
                            headers=req_head, json=req_data)
        return resp

    def del_def(self, emp_id, req_head):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/company/department/" + emp_id,
                               headers=req_head)
        return resp


if __name__ == '__main__':
    dee = DefManageApi()
    # 添加员工
    # req_head = {"Content-Type": "application/json", "Authorization": "df2e0093-75f3-444d-888c-eff40d5f7ad8"}
    # req_body = {"name":"测试部","code":"00002"}
    # # 添加员工
    # ret = dee.add_def(req_head, req_body)
    # print(ret.json())


    def_id = "1570682904583876608"
    del_req_head = {"Authorization": "9e96faef-77bb-4580-94d7-8ef589a06348"}
    ret = dee.query_def(def_id, del_req_head)
    print(ret.json())
